
<%@ page import="Answer" %>
<html>
  <head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="layout" content="main" />
  <g:set var="entityName" value="${message(code: 'answer.label', default: 'Answer')}" />
  <title>第${params.questionId}题</title>
</head>
<body>
  <div class="nav">
	<span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
  </div>
<g:render template="menu"/>
<div class="body">
  <g:if test="${flash.message}">
	<div class="message">${flash.message}</div>
  </g:if>
  <g:hasErrors bean="${answerInstance}">
	<div class="errors">
	  <g:renderErrors bean="${answerInstance}" as="list" />
	</div>
  </g:hasErrors>
  <div>${session.userName}</div>

  <g:form action="save" method="post" >
	<div class="dialog">
	  <table>
		<tbody>

		  <tr class="prop">
			<td valign="top" class="name">
			  <label for="answerId"><g:message code="question.label" default="Question" />${params.questionId}. </label>
			</td>
			<td valign="top" class="value ${hasErrors(bean: answerInstance, field: 'answerId', 'errors')}">${question.content}</td>
		  </tr>
		<g:if test="${answerInstance==null}"><tr><td colspan="2"><div class="errors">您已经完成本题，不能再次答题</div></td></tr></g:if>


		<g:if test="${answerInstance?.question?.type=='multi_select'}">
		  <tr class="prop">
			<td valign="top" class="name">
			  <label for="answerId"><g:message code="questionItem.label" default="Question Item" /></label>
			</td>
			<td valign="top" class="value ${hasErrors(bean: answerInstance, field: 'question', 'errors')}">
		  <g:each in="${answerInstance?.question?.questionItems}" var="qi">${qi.quesItemId} . ${qi.content}&nbsp;&nbsp;&nbsp;&nbsp;</g:each>

		  </td>
		  </tr>
		</g:if>

		</tbody>
	  </table>
	</div>


	<g:if test="${answerInstance!=null}">
	  <g:if test="${answerInstance?.question?.type=='multi_select'}">
		<div class="dialog">
		  <table>
			<tbody>

			  <tr class="prop">
				<td valign="top" class="name">
				  <label for="answerId"><g:message code="answer.label" default="Answer" /></label>
				</td>
				<td valign="top" class="value ${hasErrors(bean: answerInstance, field: 'answer', 'errors')}">
			<g:hiddenField name="questionId" value="${answerInstance?.question?.id}"/>
			<g:each in="${1..answerInstance?.question?.multiSelect}" var="i">${i} . <g:select name="selectedAnswerItems" from="${answerInstance?.question?.questionItems}" noSelection="${['null':'选择...']}" optionKey="quesItemId"/><br/>
			</g:each>
			</td>
			</tr>
			<tr class="prop">
			  <td valign="top" class="name">
			  </td>
			  <td valign="top" class="value ${hasErrors(bean: answerInstance, field: 'answer', 'errors')}">
				<label for="answerText">其他：（如果选择“其他”请填写详细内容）</label>
			<g:textArea name="answerText" cols="80" rows="8" style="width:150;height:80"/>
			</td>
			</tr>
			</tbody>
		  </table>
		</div>
	  </g:if>

	  <g:if test="${answerInstance?.question?.type=='answer'}">
		<div class="dialog">
		  <table>
			<tbody>

			  <tr class="prop">
				<td valign="top" class="name">
				  <label for="answerText"><g:message code="answer.label" default="Answer" /></label>
				</td>
				<td valign="top" class="value ${hasErrors(bean: answerInstance, field: 'answer', 'errors')}">
			<g:hiddenField name="questionId" value="${answerInstance?.question?.id}"/>
			<g:textArea name="answerText" cols="80" rows="8" style="width:600;height:200"/>
			</td>
			</tr>

			</tbody>
		  </table>
		</div>
	  </g:if>
	</g:if>
	<g:if test="${answerInstance!=null}">
	  <div class="buttons">
		<span class="button">
		  <g:submitButton name="create" class="save" value="保存并进入下一题" />
		</span>
	  </div>
	</g:if>
  </g:form>
</div>
</body>
</html>
